package link.anyauto.weclass.base;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.databinding.BaseObservable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import link.anyauto.weclass.R;
import link.anyauto.weclass.common.vm.AppBarVM;

/**
 * Created by discotek on 17-1-22.
 */

public class BaseVMAdapter extends BaseObservable implements BaseVM {

    protected Activity activity;
    public AppBarVM barVM = new AppBarVM(App.getDraw(R.mipmap.ic_menu_back), null, null, new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            back();
        }
    });

    public BaseVMAdapter navLogo(int logoId) {
        return navLogo(App.getDraw(logoId));
    }

    public BaseVMAdapter navLogo(Drawable logo) {
        barVM.navLogo.set(logo);
        return this;
    }

    public BaseVMAdapter title(int titleId) {
        return title(App.getStr(titleId));
    }

    public BaseVMAdapter title(String title) {
        barVM.title.set(title);
        return this;
    }

    public BaseVMAdapter subTitle(int subTitleId) {
        return subTitle(App.getStr(subTitleId));
    }

    public BaseVMAdapter subTitle(String subTitle) {
        barVM.subTitle.set(subTitle);
        return this;
    }

    public BaseVMAdapter navClick(View.OnClickListener navClick) {
        barVM.navClick.set(navClick);
        return this;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    public Activity getActivity() {
        return activity;
    }

    @Override
    public void create(Bundle savedInstanceState) {

    }

    @Override
    public void restart() {

    }

    @Override
    public void start() {

    }

    @Override
    public void stop() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void pause() {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void back() {
        if(activity != null) {
            activity.finish();
        }
    }

    @Override
    public void result(int reqCode, int resCode, Intent data) {

    }

    @Override
    public void configChanged(Configuration newConfig) {

    }

    @Override
    public boolean createOptionsMenu(MenuInflater inflater, Menu menu) {
        return false;
    }

    @Override
    public boolean optionsItemSelected(MenuItem item) {
        return false;
    }

    @Override
    public boolean prepareOptionsMenu(Menu menu) {
        return false;
    }

    @Override
    public void optionsMenuClosed(Menu menu) {
    }
}
